/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：TriggerScreen.java <br>
 * 创建时间：2015-3-9 下午9:00:45 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2.data;

import lostland.gmud.exv2.MapScreen;
import lostland.gmud.exv2.blgframework.CScreen;

/**
 * 类名：TriggerScreen <br>
 * 说明：
 *
 * @author 12548
 */
public class TriggerScreen extends CScreen {

	public boolean boolArg = false;
	public int intArg1 = 0;
	public int intArg2 = 0;
	public float floatArg = 0f;
	public String strArg = "";

	public TriggerEvent event;

	private boolean skipFrame = false;
	public int currentLine = 0;

	/**
	 */
	public TriggerScreen(TriggerEvent _event, int line, boolean _boolArg, int _intArg1, int _intArg2, float _floatArg, String _strArg) {
		super();
		event = _event;
		currentLine = line;

		boolArg = _boolArg;
		intArg1 = _intArg1;
		intArg2 = _intArg2;
		floatArg = _floatArg;
		strArg = _strArg;
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.blgframework.CScreen#present(float)
	 */
	@Override
	public void present(float deltaTime) {
		if (this == getGame().getCurrentScreen())
			getGame().getParentScreen().present(0);
		else if (MapScreen.getInstance() != null)
			MapScreen.getInstance().present(0);
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.blgframework.CScreen#pause()
	 */
	@Override
	public void pause() {
		skipFrame = true;
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.blgframework.CScreen#resume()
	 */
	@Override
	public void resume() {
		//		skipFrame = true;
	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.blgframework.CScreen#dispose()
	 */
	@Override
	public void dispose() {
		// TODO 自动生成的方法存根

	}

	/* （非 Javadoc）
	 * @see lostland.gmud.exv2.blgframework.BasicScreen#update(float)
	 */
	@Override
	public void update(float deltaTime) {
		while (true) {
			//		if(deltaTime <= 0.0001f) return;
			if (this != getGame().getCurrentScreen())
				return;
			if (skipFrame) {
				skipFrame = !skipFrame;
				return;
			}
			if (currentLine < 0 || currentLine > (event.effects.size() - 1)) {
				getGame().popScreen();
				return;
			}
			currentLine = event.effects.get(currentLine).exec(boolArg, intArg1,
					intArg2, floatArg, strArg, currentLine);
		}
	}

}
